<html>

<head>
    <script>
        //1.
        var obj = new Object();
        obj.name = "jack";
        obj.sleep = function () {
            console.log(this.name + "上课睡觉");
        }
        console.log(obj.name);
        obj.sleep();
    </script>

    <script>
        //2.
        var obj = {
            name: "jack",
            age: 18,
            sleep: function () {
                console.log(this.name + "上课睡觉");
            }
        }

        console.log(obj.name);
        obj.sleep();
    </script>
</head>

<body>

</body>

</html>